package com.zjun.mapper;



import com.zjun.pojo.MainDataPO;
import com.zjun.pojo.Result;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MainDataMapper{

    //查询数据
    @Select("select * from revenueanalysissystem.maindata")
    public List<MainDataPO> select();

    //新增数据
    @Insert("insert into revenueanalysissystem.maindata (mainId, costType, costDetail, costPrice, createTime, updateTime) values (#{mainId},#{costType},#{costDetail},#{costPrice},#{createTime},#{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "mainId")
    public void insertData(MainDataPO mainDataPO);

    //获取数据库中所有的支出类型
    @Select("SELECT DISTINCT costType FROM revenueanalysissystem.maindata;")
    public List<String> getTypeOptions();

    //获取数据库中所有的支出细分
    @Select("SELECT DISTINCT costDetail FROM revenueanalysissystem.maindata;")
    public List<String> getDetailOptions();


}
